package com.cloud.configservers;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.EmbeddedValueResolverAware;
import org.springframework.util.StringValueResolver;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@EnableConfigServer
@EnableEurekaClient
@RestController
public class ConfigServersApplication implements EmbeddedValueResolverAware {

    String prot;

    public static void main(String[] args) {
        SpringApplication.run(ConfigServersApplication.class, args);
    }

    @RequestMapping("/hi")
    public String hi(){
        return "i am config-servers , port : " + prot;
    }

    @Override
    public void setEmbeddedValueResolver(StringValueResolver stringValueResolver) {
        this.prot=stringValueResolver.resolveStringValue("${server.port}");
    }
}
